package com.sanpu.kxe.business.main.fragment;

import android.view.View;

import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseFragment;
import com.sanpu.kxe.business.main.provider.MainOpenProvider;
import com.sanpu.kxe.common.interfaces.UrlConstants;
import com.sanpu.kxe.common.view.CommonTitleView;
import com.sanpu.kxe.module.immersionbar.ImmersionBar;
import com.sanpu.kxe.rxservice.RequestMap;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Description：推广
 * Created by 薛勇军 on 2018/7/9.
 */

public class PromoteFragment extends BaseFragment {

    @Bind(R.id.commonTitle)
    CommonTitleView commonTitle;

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisible()) {
            ImmersionBar mImmersionBar = ImmersionBar.with(this);
            mImmersionBar.statusBarColorTransformEnable(true)
                    .statusBarDarkFont(true, 0.2f)
                    .statusBarView(ButterKnife.findById(mRootView, R.id.topView2))
                    .init();
        }
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.fragment_promote;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("推广");
        commonTitle.hiddenLeftView();
    }

    @OnClick({R.id.shareReg, R.id.promotePoster, R.id.offlineMaterial, R.id.myQrcode})
    public void onClick(View view) {
        try {
            switch (view.getId()) {
                case R.id.shareReg:
                    String url = UrlConstants.SHAREAPP + "?" + new RequestMap().map2ReqStr();
                    MainOpenProvider.getInstance().openBrowserX5Activity(getContext(), url, true);
                    break;
                case R.id.promotePoster:
                    MainOpenProvider.getInstance().openPromotePosterActivity(getContext());
                    break;
                case R.id.offlineMaterial:
                    MainOpenProvider.getInstance().openPushMaterialActivity(getContext());
                    break;
                case R.id.myQrcode:
                    MainOpenProvider.getInstance().openMyQrcodeActivity(getContext());
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
